home *** CD-ROM | disk | FTP | other *** search
/ TPUG - Toronto PET Users Group / TPUG Users Group CD / TPUG Users Group CD.iso / AMIGA / AMICUS / AMICUS16.ADF / C / ShowPrint / pdump2.c < prev    next >
C/C++ Source or Header  |  1989-01-27  |  2KB  |  94 lines

  1. /* Print Dump */ 
  2. #include <exec/types.h>
  3. #include <intuition/intuition.h>
  4. #include <devices/printer.h>
  5.  
  6. static struct IODRPReq request;
  7. static struct MsgPort *printerPort;
  8. extern struct MsgPort *CreatePort();
  9. extern void  *GetMsg(), *OpenLibrary(), *OpenWindow();
  10. struct IntuitionBase *IntuitionBase;
  11. struct IntuiMessage *mes;
  12.  
  13. #define ESC 0x45
  14.  
  15.  
  16. pdump(w)
  17. struct Window *w;
  18. {
  19.     register struct IODRPReq *req=&request;
  20.     
  21.     struct Screen *screen;
  22.     struct RastPort *rp;
  23.     struct ViewPort *vp;
  24.     struct ColorMap *cm;
  25.     int width,height;
  26.     long error,modes;
  27.  
  28.     ULONG class;
  29.     UWORD code;
  30.     int result;
  31.  
  32.  
  33.     screen=w->WScreen;
  34.     vp=&screen->ViewPort;
  35.     rp=&screen->RastPort;
  36.     cm=vp->ColorMap;
  37.     modes=vp->Modes;
  38.     width=vp->DWidth;
  39.     height=vp->DHeight;
  40.     if((printerPort=CreatePort(NULL,0L))==NULL)
  41.     {
  42.         printf("Couldn't Create Port\n");
  43.         return(0);
  44.     }
  45.     if(OpenDevice("printer.device",0L,req,0L))
  46.     {
  47.         printf("Couldn't open printer device\n");
  48.         DeletePort(printerPort);
  49.         return(0);
  50.     }
  51.     req->io_Command=PRD_DUMPRPORT;
  52.     req->io_RastPort=rp;
  53.     req->io_ColorMap=cm;
  54.     req->io_Modes=modes;
  55.     req->io_Message.mn_ReplyPort=printerPort;
  56.     req->io_SrcX=0;
  57.     req->io_SrcY=0;
  58.     req->io_SrcWidth=width;
  59.     req->io_SrcHeight=height;
  60.     req->io_DestCols=width;
  61.     req->io_DestRows=height;
  62.     req->io_Special=0xCC;
  63.     SendIO(req);
  64.  
  65.     while((CheckIO(req))==FALSE)
  66.     {
  67.         if((mes=(struct IntuiMessage *)GetMsg(w->UserPort))==0L)
  68.         {
  69.             Wait(1L<<w->UserPort->mp_SigBit);
  70.             continue;
  71.         }
  72.         class=mes->Class;
  73.         code=mes->Code;
  74.         ReplyMsg(mes);
  75.         switch(class)
  76.         {
  77.             case RAWKEY    :    if(code==ESC)
  78.                         {    
  79.                             req->io_Command=CMD_RESET;                
  80.                             BeginIO(req);
  81.                             WaitIO(req);
  82.                             goto cleanup3;
  83.                         }
  84.                         break;
  85.                     
  86.         }
  87.     }
  88. cleanup3:
  89.      CloseDevice(&request);
  90. cleanup2:
  91.     DeletePort(printerPort);
  92. }
  93.  
  94.